package ocp

import (
    `io`
    `net/http`
)

// 开闭成功

func BuildOutputOCPSuccess(w http.ResponseWriter, formatter PersonFormatter, person Person) {
    err := formatter.Format(w, person)
    if err != nil {
        // output a server error and quit
        w.WriteHeader(http.StatusInternalServerError)
        return
    }
    w.WriteHeader(http.StatusOK)

}

type PersonFormatter interface {
    Format(writer io.Writer, person Person) error
}

// output the person as CSV
type CSVPersonFormatter struct {
}

// Format implements the PersonFormatter interface
func (c *CSVPersonFormatter) Format(writer io.Writer, person Person) error {
    // todo:implement
    return nil
}

// output the person as JSON

type JSONPersonFormatter struct {
}

// Format implements the PersonFormatter interface

func (j *JSONPersonFormatter) Format(writer io.Writer, person Person) error {
    // todo :implement
    return nil
}
